home *** CD-ROM | disk | FTP | other *** search
/ IRIX Base Documentation 2001 May / SGI IRIX Base Documentation 2001 May.iso / usr / share / catman / p_man / cat3 / librw / RWFactory.z / RWFactory
Encoding:
Text File  |  1998-10-30  |  9.4 KB  |  199 lines

  1.  
  2.  
  3.  
  4. RRRRWWWWFFFFaaaaccccttttoooorrrryyyy((((3333CCCC++++++++))))                                                RRRRWWWWFFFFaaaaccccttttoooorrrryyyy((((3333CCCC++++++++))))
  5.  
  6.  
  7.  
  8. NNNNaaaammmmeeee
  9.      RWFactory - Rogue Wave library class
  10.  
  11. SSSSyyyynnnnooooppppssssiiiissss
  12.               typedef unsigned short  RWClassID;
  13.  
  14.  
  15.  
  16.               typedef RWCollectable*  (*RWuserCreator)();
  17.           #include <rw/factory.h>
  18.           RWFactory* theFactory;
  19.  
  20.  
  21.  
  22.  
  23. DDDDeeeessssccccrrrriiiippppttttiiiioooonnnn
  24.      Class RRRRWWWWFFFFaaaaccccttttoooorrrryyyy can create an instance of an RRRRWWWWCCCCoooolllllllleeeeccccttttaaaabbbblllleeee object, given
  25.      a class ID.  It does this by maintaining a table of class IDs and
  26.      associated "creator functions."  A creator function has prototype:
  27.  
  28.               RWCollectable*  aaaaCCCCrrrreeeeaaaattttoooorrrrFFFFuuuunnnnccccttttiiiioooonnnn();
  29.  
  30.  
  31.  
  32.  
  33.  
  34.      This function should create an instance of a particular class.  For a
  35.      given RRRRWWWWCCCCllllaaaassssssssIIIIDDDD tag, the appropriate function is selected, invoked and
  36.      the resultant pointer returned.  Because any object created this way is
  37.      created off the heap, you are responsible for deleting it when done.
  38.      There is a one-of-a-kind global RRRRWWWWFFFFaaaaccccttttoooorrrryyyy which can be accessed using
  39.      ggggeeeettttRRRRWWWWFFFFaaaaccccttttoooorrrryyyy.  It is guaranteed to have creator functions in it for all
  40.      of the classes referenced by your program.  See also the section in the
  41.      User's Guide about RRRRWWWWFFFFaaaaccccttttoooorrrryyyy.
  42.  
  43. PPPPeeeerrrrssssiiiisssstttteeeennnncccceeee
  44.      None
  45.  
  46. EEEExxxxaaaammmmpppplllleeee
  47.               #include <rw/factory.h>
  48.           #include <rw/rwbag.h>
  49.           #include <rw/colldate.h>
  50.           #include <rw/rstream.h>
  51.           main(){
  52.            // Create new RWBag off the heap, using Class ID __RWBAG.
  53.            RWBag* b = (RWBag*)getRWFactory ()->create(__RWBAG);
  54.            b->insert( new RWCollectableDate ); // Insert today's date
  55.            // ...
  56.            b->clearAndDestroy();     // Cleanup: first delete members,
  57.            delete b;                 // then the bag itself
  58.           }
  59.  
  60.  
  61.  
  62.  
  63.                                                                         PPPPaaaaggggeeee 1111
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70. RRRRWWWWFFFFaaaaccccttttoooorrrryyyy((((3333CCCC++++++++))))                                                RRRRWWWWFFFFaaaaccccttttoooorrrryyyy((((3333CCCC++++++++))))
  71.  
  72.  
  73.  
  74. PPPPuuuubbbblllliiiicccc CCCCoooonnnnssssttttrrrruuuuccccttttoooorrrrssss
  75.               RRRRWWWWFFFFaaaaccccttttoooorrrryyyy();
  76.  
  77.  
  78.      Construct an RRRRWWWWFFFFaaaaccccttttoooorrrryyyy.
  79.  
  80. PPPPuuuubbbblllliiiicccc  OOOOppppeeeerrrraaaattttoooorrrr
  81.               RWBoolean
  82.           ooooppppeeeerrrraaaattttoooorrrr<<<<====(const RWFactory& h);
  83.  
  84.  
  85.      Returns TTTTRRRRUUUUEEEE  if self is a subset of hhhh, that is, every element of self
  86.      has a counterpart in hhhh which iiiissssEEEEqqqquuuuaaaallll.  This operator is included to fix
  87.      an inconsistency in the C++ language.  It is not explicitly present
  88.      unless you are compiling with an implementation of the Standard C++
  89.      Library.   It would normally be inherited from RRRRWWWWSSSSeeeetttt NNNNooootttteeee:  If you
  90.      inherit from RRRRWWWWFFFFaaaaccccttttoooorrrryyyy in the presence of the Standard C++ Library, we
  91.      recommend that you override this operator and explicitly forward the
  92.      call.  Overload resolution in C++ will choose the Standard Library
  93.      provided global operators over inherited class members.  These global
  94.      definitions are not appropriate for set-like partial orderings.
  95.  
  96. PPPPuuuubbbblllliiiicccc MMMMeeeemmmmbbbbeeeerrrr FFFFuuuunnnnccccttttiiiioooonnnnssss
  97.               void
  98.           aaaaddddddddFFFFuuuunnnnccccttttiiiioooonnnn(RWuserCreator uc, RWClassID id);
  99.  
  100.  
  101.      Adds to the RRRRWWWWFFFFaaaaccccttttoooorrrryyyy the global function pointed to by uuuucccc, which creates
  102.      an instance of an object with RRRRWWWWCCCCllllaaaassssssssIIIIDDDD iiiidddd.
  103.  
  104.               void
  105.           aaaaddddddddFFFFuuuunnnnccccttttiiiioooonnnn(RWuserCreator uc, RWClassID id, RWStringID sid);
  106.  
  107.  
  108.      Adds to the RRRRWWWWFFFFaaaaccccttttoooorrrryyyy the global function pointed to by uuuucccc, which creates
  109.      an instance of an object with RRRRWWWWCCCCllllaaaassssssssIIIIDDDD iiiidddd and RRRRWWWWSSSSttttrrrriiiinnnnggggIIIIDDDD ssssiiiidddd.
  110.  
  111.               RWCollectable*
  112.           ccccrrrreeeeaaaatttteeee(RWClassID id) const;
  113.  
  114.  
  115.      Allocates a new instance of the class with RRRRWWWWCCCCllllaaaassssssssIIIIDDDD iiiidddd off the heap and
  116.      returns a pointer to it.  Returns nnnniiiillll if iiiidddd does not exist.  Because this
  117.      instance is allocated ooooffffffff tttthhhheeee hhhheeeeaaaapppp, you are responsible for deleting it
  118.      when done.
  119.  
  120.               RWCollectable*
  121.           ccccrrrreeeeaaaatttteeee(RWString sid) const;
  122.  
  123.  
  124.      Allocates a new instance of the class with RRRRWWWWSSSSttttrrrriiiinnnnggggIIIIDDDD ssssiiiidddd off the heap
  125.      and returns a pointer to it.  Returns nnnniiiillll if ssssiiiidddd does not exist.  Because
  126.  
  127.  
  128.  
  129.                                                                         PPPPaaaaggggeeee 2222
  130.  
  131.  
  132.  
  133.  
  134.  
  135.  
  136. RRRRWWWWFFFFaaaaccccttttoooorrrryyyy((((3333CCCC++++++++))))                                                RRRRWWWWFFFFaaaaccccttttoooorrrryyyy((((3333CCCC++++++++))))
  137.  
  138.  
  139.  
  140.      this instance is allocated ooooffffffff tttthhhheeee hhhheeeeaaaapppp, you are responsible for deleting
  141.      it when done.
  142.  
  143.               RWuserCreator
  144.           ggggeeeettttFFFFuuuunnnnccccttttiiiioooonnnn(RWClassID id) const;
  145.  
  146.  
  147.      Returns from the RRRRWWWWFFFFaaaaccccttttoooorrrryyyy a pointer to the global function associated
  148.      with RRRRWWWWCCCCllllaaaassssssssIIIIDDDD iiiidddd.  Returns nnnniiiillll if iiiidddd does not exist.
  149.  
  150.               RWuserCreator
  151.           ggggeeeettttFFFFuuuunnnnccccttttiiiioooonnnn(RWStringID sid) const;
  152.  
  153.  
  154.      Returns from the RRRRWWWWFFFFaaaaccccttttoooorrrryyyy a pointer to the global function associated
  155.      with RRRRWWWWSSSSttttrrrriiiinnnnggggIIIIDDDD ssssiiiidddd.  Returns nnnniiiillll if ssssiiiidddd does not exist.
  156.  
  157.               void
  158.           rrrreeeemmmmoooovvvveeeeFFFFuuuunnnnccccttttiiiioooonnnn(RWClassID id);
  159.  
  160.  
  161.      Removes from the RRRRWWWWFFFFaaaaccccttttoooorrrryyyy the global function associated with RRRRWWWWCCCCllllaaaassssssssIIIIDDDD
  162.      iiiidddd.  If iiiidddd does not exist in the factory, no action is taken.
  163.  
  164.               void
  165.           rrrreeeemmmmoooovvvveeeeFFFFuuuunnnnccccttttiiiioooonnnn(RWStringID sid);
  166.  
  167.  
  168.      Removes from the RRRRWWWWFFFFaaaaccccttttoooorrrryyyy the global function associated with RRRRWWWWSSSSttttrrrriiiinnnnggggIIIIDDDD
  169.      ssssiiiidddd.  If ssssiiiidddd does not exist in the factory, no action is taken.
  170.  
  171.               RWStringID
  172.           ssssttttrrrriiiinnnnggggIIIIDDDD(RWClassID id) const;
  173.  
  174.  
  175.      Looks up the RRRRWWWWSSSSttttrrrriiiinnnnggggIIIIDDDD associated with iiiidddd and returns it.  If there is
  176.      no such association, returns  RRRRWWWWSSSSttttrrrriiiinnnnggggIIIIDDDD((((""""NNNNooooIIIIDDDD"""")))).
  177.  
  178.               RWClassID
  179.           ccccllllaaaassssssssIIIIDDDD(RWStringID) const;
  180.  
  181.  
  182.      Looks up the RRRRWWWWCCCCllllaaaassssssssIIIIDDDD associated with ssssiiiidddd and returns it.  If there is
  183.      no such association, returns ________RRRRWWWWUUUUNNNNKKKKNNNNOOOOWWWWNNNN.
  184.  
  185.  
  186.  
  187.  
  188.  
  189.  
  190.  
  191.  
  192.  
  193.  
  194.  
  195.                                                                         PPPPaaaaggggeeee 3333
  196.  
  197.  
  198.  
  199.